package com.ccrfid.rmc6.resource.sys;

import com.ccrfid.rmc6.appconfig.auth.Secured;
import com.ccrfid.rmc6.entity.sys.KeyValueEntity;
import com.ccrfid.rmc6.service.sys.KeyValueService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

@Secured
@Path("kv")
@Produces(MediaType.APPLICATION_JSON)
public class KeyValueResource {
    @Autowired
    private KeyValueService keyValueService;

    @GET
    @Path("{key}")
    public KeyValueEntity getkeyValue(@PathParam("key") String key) {
        return keyValueService.getKeyValue(key);
    }

    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    public Boolean saveKeyValue(KeyValueEntity entity) {
        keyValueService.saveKeyValue(entity);
        return true;
    }
}
